import React, { Component } from "react";
//css
import { MenuFoldOutlined } from "@ant-design/icons";
import "./asicle.scss";
export default class Header extends Component {
  state = {
    collapsed: this.props.collapsed,
  };
  //监听父组件传递过来的props值的变化
  componentWillReceiveProps({ collapsed }) {
    this.setState({ collapsed });
  }
  toggleMenu = () => {
    this.props.toggle();
  };
  render() {
    const { collapsed } = this.state;
    return (
      <div className={collapsed ? "collpased-close " : ""}>
        <h1 className="logo">
          <span>logo</span>
        </h1>
        <div className="headers-warp">
          <span onClick={this.toggleMenu} className="collpased-icon">
            <MenuFoldOutlined />
          </span>
        </div>
      </div>
    );
  }
}
